<?php
/**
 * Created by PhpStorm.
 * User: gakuin
 * Date: 16/8/28
 * Time: 上午10:11
 */
namespace app\controllers;

use app\models\Category;
use app\models\Commodity;
use yii\web\Controller;

class CategoryController extends Controller{
    public $layout = 'layout';

    public function actionCategoryList(){
        $title = \Yii::$app->request->get('type');
        $share_id = \Yii::$app->request->get('share_id');
        $commodityModel = new Commodity();
        $category = new Category();
        $first_category = $category->getCategoryId($title);
        $commodity_ids = $commodityModel->getCommodityIds($first_category);
        $commodities = $commodityModel->getCommodities($commodity_ids);
        return $this->render('category-list',['title' => $title,'commodities' => $commodities,'share_id' => $share_id]);
    }
}